
package com.bei_en.teacher.third.pay.controller;

import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import com.bei_en.common.spring.DateEditor;
import com.bei_en.common.spring.DoubleEditor;
import com.bei_en.common.spring.IntegerEditor;
import com.bei_en.common.spring.LongEditor;
import com.bei_en.common.util.LogUtil;
import com.bei_en.common.web.MySessionContext;
import com.google.gson.Gson;

public abstract class BaseController {

    protected Logger log = Logger.getLogger(this.getClass());
    public Gson gson = new Gson();

    // protected WpLogger wplog = Logger.getLogger(this.getClass());
    @Autowired
    protected HttpServletRequest request;

    // @Autowired
    // protected HttpServletResponse response;
    /*
        @Autowired
        private ResourceBundleMessageSource _res;*/

    // @Autowired
    // protected SpringContextHolder _contextHolder;

    @InitBinder
    protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
	    throws Exception {

	binder.registerCustomEditor(int.class, new IntegerEditor());
	binder.registerCustomEditor(long.class, new LongEditor());
	binder.registerCustomEditor(double.class, new DoubleEditor());
	binder.registerCustomEditor(Date.class, new DateEditor());
    }

    /*@ExceptionHandler(Exception.class)
    public String exception(Exception e, HttpServletRequest request, HttpServletResponse response,
        String msg) {

    e.printStackTrace();
    log.warn(msg);
    request.setAttribute("exception", e);

    if (ServerInfo.isAjax(request)||request.getParameter("ajax")!=null) {
        writeDwzSignal("300", msg, "", "", null, response);

        return null;
    }

    // ModelAndView mav = new ModelAndView("error.html");
    // mav.addObject("statusCode", 300);
    // mav.addObject("message", msg);
    request.setAttribute("statusCode", 300);
    request.setAttribute("message", msg);

    return "error";
    }*/
    public HttpServletRequest getRequest() {

	return request;
    }
}
